//
//  HomePageView.m
//  EverydayDemo
//
//  Created by qianfeng01 on 15-7-18.
//  Copyright (c) 2015年 qianfeng01. All rights reserved.
//

#import "HomePageView.h"
#import "UIImageView+WebCache.h"
#import "HomePageModel.h"
@implementation HomePageView

-(void)setData:(NSMutableArray *)dataArr
{
    for (int i=0; i<dataArr.count; i++) {
        HomePageModel *model=[[HomePageModel alloc]init];
        model=dataArr[i];
         UIImageView * imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0,i*(kScreenSize.height-64), kScreenSize.width,  kScreenSize.height-64)];
        [imageView sd_setImageWithURL:[NSURL URLWithString:model.imageUrl]placeholderImage:[UIImage imageNamed:@"default_article_cover.png"]];
        [self addSubview:imageView];
        UILabel * titleLabel=[[UILabel alloc]initWithFrame:CGRectMake(0,  kScreenSize.height-200, imageView.frame.size.width, 30)];
       titleLabel.text=model.title;
        titleLabel.textColor=[UIColor whiteColor];
        titleLabel.textAlignment=NSTextAlignmentCenter;
        [imageView addSubview:titleLabel];
        UILabel *categoryLabel=[[UILabel alloc]initWithFrame:CGRectMake(0, kScreenSize.height-170,(imageView.frame.size.width/2)-40, 30)];
        categoryLabel.textAlignment=NSTextAlignmentRight;
        categoryLabel.font=[UIFont boldSystemFontOfSize:12.0];
        categoryLabel.text=model.categryName;
        categoryLabel.textColor=[UIColor yellowColor];
        [imageView addSubview:categoryLabel];
        UILabel *authorLabel=[[UILabel alloc]initWithFrame:CGRectMake((imageView.frame.size.width/2), kScreenSize.height-170,imageView.frame.size.width/2, 30)];
       authorLabel.text=model.authorName;
        authorLabel.textColor=[UIColor whiteColor];
        authorLabel.font=[UIFont boldSystemFontOfSize:12.0];
        [imageView addSubview:authorLabel];

    }
    self.pagingEnabled = YES;
    self.contentSize = CGSizeMake(kScreenSize.width, dataArr.count*(kScreenSize.height-64));
}
@end
